package mn.more.mock.io;

import java.io.File;
import java.io.IOException;

/**
 * general description of a {@link MockModel} writer -- specialized class that
 * can persist the mock data into external location.  Implementation class can
 * choose its own method of persistence, including storing to database. However,
 * a get/set method for <code>filename</code> is provided since it is common to
 * saving model data to file.
 *
 * @author <a href="mailto:mike.liu@aptechmongolia.edu.mn">Mike Liu</a>
 * @version $Id: MockDataWriter.java 5 2008-09-01 12:08:42Z mikeliucc $
 */
public interface MockDataWriter {

	/**
	 * @return the filename used for writing mock data -- this should be the full
	 *         path.
	 */
	String getFilename();

	/**
	 * @param filename  the name of the file used for writing mock data, which can
	 *                  either be full path or relative to current classpath.
	 * @param classpath determine whether <code>filename</code> is absolution path
	 *                  or relative to current classpath
	 */
	void setFilename(String filename, boolean classpath);

	/**
	 * write operation is implemented here.  Implementation class will choose its
	 * own mechanism for persisting model information, including saving to
	 * database.
	 */
	void write(MockModel model) throws IOException;

	/** added to support spring's bean property setter, assume full path */
	void setFile(File file);
}
